const connection = require("../db")
class artistcataServe {
  getcatalist() {
    const statement =
      "select * from  article_cate where is_delete = 0 order by id"
    return connection.execute(statement)
  }
  iscatenameexit(name) {
    const statement =
      "select * from article_cate where name=? and is_delete = 0 "
    return connection.execute(statement, [name])
  }
  iscatealiasexit(name) {
    const statement =
      "select * from article_cate where alias=? and is_delete = 0 "
    return connection.execute(statement, [name])
  }
  updatacate(name, alias) {
    const statement = "INSERT INTO article_cate (alias,name) VALUES(?,?)"
    return connection.execute(statement, [alias, name])
  }
  deletecate(id) {
    const statement = " UPDATE `article_cate` SET is_delete = ? WHERE id = ?"
    return connection.execute(statement, [1, id])
  }
  getcatasbyid(id) {
    const statement =
      "select * from  article_cate where id = ? and is_delete = 0 order by id"
    return connection.execute(statement, [id])
  }
  updatacatebyid(id, name, alais) {
    const statement = "UPDATE article_cate SET name =?,alias=? WHERE id = ?"
    return connection.execute(statement, [name, alais, id])
  }
}

module.exports = new artistcataServe()
